package site.wanjiahao.handler.server;

import io.netty.channel.ChannelHandler;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundHandlerAdapter;
import lombok.extern.slf4j.Slf4j;
import site.wanjiahao.app.Server;

@Slf4j
@ChannelHandler.Sharable
public class ClientClosingHandler extends ChannelInboundHandlerAdapter {
    @Override
    public void channelInactive(ChannelHandlerContext ctx) throws Exception {
        log.debug("客户端正常关闭");
        ctx.channel().close();
    }

    @Override
    public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
        log.debug("客户端异常关闭");
        cause.printStackTrace();
        ctx.channel().close();
    }
}
